﻿
using Xacml.Core;
using System.Xml;

namespace Xacml.Core.Policy
{
  public abstract class AttributeDesignatorBase : AttributeReferenceBase
  {
    private string _attributeId = string.Empty;
    private string _issuer = string.Empty;

    public string AttributeId
    {
      get
      {
        return this._attributeId;
      }
      set
      {
        this._attributeId = value;
      }
    }

    public string Issuer
    {
      get
      {
        return this._issuer;
      }
      set
      {
        this._issuer = value;
      }
    }

    protected AttributeDesignatorBase(string dataType, bool mustBePresent, string attributeId, string issuer, XacmlVersion version)
      : base(dataType, mustBePresent, version)
    {
      this._attributeId = attributeId;
      this._issuer = issuer;
    }

    protected AttributeDesignatorBase(XmlReader reader, XacmlVersion version)
      : base(reader, version)
    {
      this._attributeId = reader.GetAttribute("AttributeId");
      this._issuer = reader.GetAttribute("Issuer");
      if (this._issuer != null)
        return;
      this._issuer = string.Empty;
    }

    public override string ToString()
    {
      return "[" + this._attributeId + "[" + this.DataType + "]]";
    }
  }
}
